package com.hao.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hao.study.entity.ErrorLog;
import com.hao.study.service.ErrorLogService;
import com.hao.study.mapper.ErrorLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【b_error_log】的数据库操作Service实现
* @createDate 2024-06-13 09:54:46
*/
@Service
public class ErrorLogServiceImpl extends ServiceImpl<ErrorLogMapper, ErrorLog>
    implements ErrorLogService{
    @Autowired
    ErrorLogMapper mapper;

    @Override
    public PageInfo<ErrorLog> getErrorLogList(Integer pageNum, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<ErrorLog> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(keyword)){
            queryWrapper.like("ip",keyword);
        }
        return PageInfo.of(mapper.selectList(queryWrapper));
    }

    @Override
    public void createErrorLog(ErrorLog errorLog) {
        mapper.insert(errorLog);
    }

    @Override
    public void deleteErrorLog(String id) {
        mapper.deleteById(id);
    }

    @Override
    public void updateErrorLog(ErrorLog errorLog) {
        mapper.updateById(errorLog);
    }
}




